Blockly.Python['demjson_package'] = function(block) {
    return "import demjson \n";
};

Blockly.Python['demjson_create'] = function(block) {
    return ['{}', Blockly.Python.ORDER_ATOMIC];
};

Blockly.Python['demjson_decode'] = function(block) {
    var string = Blockly.Python.valueToCode(block, 'STRING', Blockly.Python.ORDER_ATOMIC) || '{}';
    return ['demjson.decode(' + string + ')', Blockly.Python.ORDER_ATOMIC];
};

Blockly.Python['demjson_encode'] = function(block) {
    var json = Blockly.Python.valueToCode(block, 'JSON', Blockly.Python.ORDER_ATOMIC);
    return ['demjson.encode(' + json + ')', Blockly.Python.ORDER_ATOMIC];
};

Blockly.Python['demjson_get'] = function(block) {
    var json = Blockly.Python.valueToCode(block, 'JSON', Blockly.Python.ORDER_ATOMIC);
    var property = Blockly.Python.valueToCode(block, 'PROPERTY', Blockly.Python.ORDER_ATOMIC);
    return [json + '[' + property + ']', Blockly.Python.ORDER_ATOMIC];
};

Blockly.Python['demjson_set'] = function(block) {
    var json = Blockly.Python.valueToCode(block, 'JSON', Blockly.Python.ORDER_ATOMIC);
    var property = Blockly.Python.valueToCode(block, 'PROPERTY', Blockly.Python.ORDER_ATOMIC);
    var value = Blockly.Python.valueToCode(block, 'VALUE', Blockly.Python.ORDER_ATOMIC);
    return json + '[' + property + '] = ' + value + ' \n';
};